package com.example.cargetter.pojo;

/**
 * 第一辆小车的数据。
 */
public class CarData {
    //单例模式，防止频繁调用出错。
    private static CarData carData;
    private double lat,lon;  // 经纬度
    private double speed;   //速度
    private double altitude; // 海拔高度，预警判断用。

    private double distance;   //两车相撞场景下的两车间距。



    private CarData(double lat, double lon,double speed, double altitude){
        this.lat = lat;
        this.lon = lon;
        this.speed = speed;
        this.altitude = altitude;
    }

    private CarData(){}

    //在调用时，没有调用过就初始化并返回对象，已调用就赋予新的经纬度并返回对象
    public static CarData getInstance(double lat,double lon,double speed, double altitude) {
        if (carData == null) {
            carData = new CarData(lat,lon,speed,altitude);
        }
        return carData;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLon() {
        return lon;
    }

    public void setLon(double lon) {
        this.lon = lon;
    }

    public double getSpeed() {
        return speed;
    }

    public void setSpeed(double speed) {
        this.speed = speed;
    }


    public double getDistance() {
        return distance;
    }

    public void setDistance(double distance) {
        this.distance = distance;
    }
}
